/**
 * @file	CameraTest.cpp
 *
 * @brief	Implements the camera test class.
 * 			
 * @author	Erica Zhao
 */

#include <iostream>
#include "Enums.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "CameraAgent.h"
#include "NestAgentMock.h"
#include "Camera.h"
#include "Nest.h"
#include <string>

class CameraAgent;
class Nest;

std::string CamTestString = "Camera Test";

class CameraTest : public ::testing::Test 
{
public:

	CameraAgent camera;
	NestAgentMock nestMock;
	//GUICameraMock guiCamera;
	PartType partType;
	Picture p;

	CameraTest() 
		: camera(CamTestString) 
	{
	}

	virtual void SetUp() 
	{
	}

	CameraAgent::CameraState camState() 
	{
		return camera.state;
	}

	bool didGuiTakePicture() 
	{
		if (camera.state == camera.TakingPicture)
			return true;
	}

	bool runSchedule() 
	{
		return camera.pickAndExecuteAnAction();
	}
};

TEST_F(CameraTest, initializationTest) 
{
	EXPECT_EQ(camState(), CameraAgent::CameraState::None);
	EXPECT_FALSE(camera.pickAndExecuteAnAction());
}

TEST_F(CameraTest, msgIThinkImFull) 
{
	//NestAgent* nest;
	//PartType partA = PartType::A;
	EXPECT_FALSE(runSchedule());
	Picture p = Unstable;

	NestAgentMock *nest = new NestAgentMock();
	camera.setNest((NestAgent*)nest);

	// Force set nest partType to A
	((NestAgent*)nest)->partType = PartType::A;
	
	// Camera's state should be None
	EXPECT_EQ(CameraAgent::CameraState::None, camState());

	// Force set Picture state to stable
	//p = Stable;

	// Check if partTypes match
	camera.msgIThinkImFull(PartType::A);
	
	// Picture state should now be set to Stable
	EXPECT_EQ(Stable, camera.p);

	// Camera's state should now be TakingPicture
	EXPECT_EQ(CameraAgent::CameraState::TakingPicture, camState());

	// Camera's state should now be TakingPicture
	EXPECT_TRUE(didGuiTakePicture());

	// Camera should send msgHereIsAPicture to nest once schedule is called
	EXPECT_CALL( (*nest) , msgHereIsAPicture(p));

}